package org.hu.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;
import org.hu.entity.dto.DishPageQueryDTO;
import org.hu.entity.pojo.Dish;

import java.util.List;

@Mapper
public interface DishMapper {

    // 添加菜品
    @Insert("insert into dish(name,category_id,price,image,description,create_time,update_time)" +
            "values (#{name},#{categoryId},#{price},#{image},#{description},#{createTime},#{updateTime})")
    void insert(Dish dish);
    // 删除菜品
    @Delete("delete from dish where id=#{id}")
    void deleteById(Integer id);

    // 修改菜品
    @Update("update dish set name=#{name},category_id=#{categoryId},price=#{price},image=#{image}" +
            ",description=#{description},count=#{count},status=#{status},update_time=#{updateTime} where id=#{id}")
    void updateById(Dish dish);

    // 条件查询菜品
    List<Dish> selectList(DishPageQueryDTO dishPageQueryDTO);

    // 将菜品的月销量置零
    @Update("update dish set count=0")
    void resetCount();
}
